package org.tp8.sampleapp.service.impl;

import javax.jws.WebService;

import org.bson.types.ObjectId;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.tp8.sampleapp.dms.model.BookDoc;
import org.tp8.sampleapp.dms.repository.BookDocRepository;
import org.tp8.sampleapp.exc.SampleAppException;
import org.tp8.sampleapp.rule.intf.RuleService;
import org.tp8.sampleapp.rule.model.RuleModelWrapper;
import org.tp8.sampleapp.service.abs.AbstractDocService;
import org.tp8.sampleapp.service.intf.BookDocService;
import org.tp8.sampleapp.util.SampleAppLogger;

/**
 * The Class CourseServiceImpl.
 */
@Transactional(propagation = Propagation.REQUIRED)
@Service(value = "bookService")
@WebService(endpointInterface = "org.tp8.sampleapp.service.intf.BookDocService")
public class BookDocServiceImpl extends
		AbstractDocService<ObjectId, BookDoc, BookDocRepository> implements
		BookDocService {

	/**
	 * The Constant log.
	 */
	public final static SampleAppLogger log = new SampleAppLogger(
			BookDocServiceImpl.class);

	/** The book doc repository. */
	@Autowired
	private BookDocRepository bookDocRepository;

	/** The rule service. */
	@Autowired
	private RuleService ruleService;

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.tp8.sampleapp.service.abs.AbstractDocService#getRepository()
	 */
	@Override
	public BookDocRepository getRepository() {
		return bookDocRepository;
	}

	/**
	 * Validate.
	 * 
	 * @param t
	 *            the t
	 * @return the rule model wrapper
	 * @throws SampleAppException
	 *             the sample app exception
	 */
	@Override
	public RuleModelWrapper validate(BookDoc item) throws SampleAppException {
		return ruleService.execute("ksBook", item);
	}

}
